<?php

namespace app\api\controller\v1;

use app\api\validate\IDCollection;
use app\api\model\Theme as ThemeModel;
use app\api\validate\IDMustBePositiveInt;
use app\lib\exception\ThemeException;

class Theme
{
    /**
     * @url /theme?ids=1,2,3...
     * @param string $ids
     * @return false|\PDOStatement|string|\think\Collection
     * @throws ThemeException
     */
    public function getSampleList($ids = '')
    {
        (new IDCollection())->goCheck();

        $themes = ThemeModel::getThemeByIDs($ids);
        if($themes->isEmpty()){
            throw new ThemeException();
        }
        return $themes;
    }

    public function getComplexOne($id)
    {
        (new IDMustBePositiveInt())->goCheck();

        $themeDetail = ThemeModel::getThemeDetailById($id);
        if($themeDetail->isEmpty()){
            throw new ThemeException();
        }
        return $themeDetail;
    }
}
